﻿using FileMonitor.Configuration.Providers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Collections.Generic;
using FileMonitor.Configuration.Prototype;
using System.Collections.Specialized;

namespace TestProject
{
    
    
    /// <summary>
    ///This is a test class for XMLProviderDataControllerTest and is intended
    ///to contain all XMLProviderDataControllerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class XMLProviderDataControllerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetAllDataBase
        ///</summary>
        [TestMethod()]
        public void GetAllDataBaseTest()
        {
            string XMLPath = @"E:\Dev Version Manage\FileMonitor V2.2\FileMonitor.Service\AppConfig.xml"; // TODO: Initialize to an appropriate value
            XMLProvider target = new XMLProvider(XMLPath); // TODO: Initialize to an appropriate value
            Dictionary<string, FileUtility.SqlDataBaseExtender> expected = new Dictionary<string, FileUtility.SqlDataBaseExtender>(); // TODO: Initialize to an appropriate value
            expected.Add("DefaultExchangeDB", new FileUtility.SqlDataBaseExtender("Database=SAPExchangeDB;Server=10.157.45.88;User Id=sa;Password=Aa000000;"));
            expected.Add("BusinessDB", new FileUtility.SqlDataBaseExtender("Database=EfoxNC;Server=10.157.45.88;User Id=sa;Password=Aa000000;"));
            Dictionary<string, FileUtility.SqlDataBaseExtender> actual;
            actual = target.GetAllDataBase();
            Assert.AreEqual(expected.Count, actual.Count);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetAllTypes
        ///</summary>
       [TestMethod()]
        public void GetAllTypesTest()
        {
            string XMLPath = @"E:\Dev Version Manage\FileMonitor V2.2\FileMonitor.Service\AppConfig.xml"; // TODO: Initialize to an appropriate value
            XMLProvider target = new XMLProvider(XMLPath); // TODO: Initialize to an appropriate value
            Dictionary<string, Type> expected = new Dictionary<string, Type>(); // TODO: Initialize to an appropriate value
            Type t1 = Type.GetType("TXTMonitor.Process");
            Type t2 = Type.GetType("XLSMonitor.Process");
            Type t3 = Type.GetType("FileMonitor.BizProcess.BizHPForecast");
            Type t4 = Type.GetType("FileMonitor.BizProcess.BizForecast");

            expected.Add("TXTMonitor",t1);
            expected.Add("XLSMonitor",t2);
            expected.Add("BizHPForecast", t3);
            expected.Add("BizForecast", t4);

            Dictionary<string, Type> actual;
            actual = target.GetAllTypes();
            Assert.AreEqual(expected.Count, actual.Count);
        }

        /// <summary>
        ///A test for GetAllProcedureProcess
        ///</summary>
        [TestMethod()]
        public void GetAllProcedureProcessTest()
        {
            string XMLPath = @"E:\Dev Version Manage\FileMonitor V2.2\FileMonitor.Service\AppConfig.xml"; // TODO: Initialize to an appropriate value
            XMLProvider target = new XMLProvider(XMLPath); // TODO: Initialize to an appropriate value
            Dictionary<string, ProcedureProcess> expected = new Dictionary<string,ProcedureProcess>(); // TODO: Initialize to an appropriate value
            expected.Add("Procedure_HPFrocastLogic", new ProcedureProcess("Procedure_HPFrocastLogic"));
            Dictionary<string, ProcedureProcess> actual;
            actual = target.GetAllProcedureProcess();
            Assert.AreEqual(expected.Count, actual.Count);
            Assert.AreEqual(actual["Procedure_HPFrocastLogic"].SourceDatabaseName, "DefaultExchangeDB");
        }

        /// <summary>
        ///A test for GetAllCSharpProcess
        ///</summary>
        [TestMethod()]
        public void GetAllCSharpProcessTest()
        {
            string XMLPath = @"E:\Dev Version Manage\FileMonitor V2.2\FileMonitor.Service\AppConfig.xml"; // TODO: Initialize to an appropriate value
            XMLProvider target = new XMLProvider(XMLPath); // TODO: Initialize to an appropriate value
            Dictionary<string, CSharpProcessBase> expected = new Dictionary<string,CSharpProcessBase>(); // TODO: Initialize to an appropriate value
            expected.Add("BizHPForecast", new FileMonitor.BizProcess.BizHPForecast("BizHPForecast"));
            expected.Add("BizForecast", new FileMonitor.BizProcess.BizForecast("BizForecast"));
            Dictionary<string, CSharpProcessBase> actual;
            actual = target.GetAllCSharpProcess();
            Assert.AreEqual("DefaultExchangeDB", actual["CSharp_HPForecastLogic"].SourceDatabaseName);
          //  Assert.AreEqual("TestValue", actual["CSharp_ForecastLogic"].ExtendableConfig["Params"]);

         //   Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetAllSpecialValues
        ///</summary>
        [TestMethod()]
        public void GetAllSpecialValuesTest()
        {
            string XMLPath = @"E:\Dev Version Manage\FileMonitor V2.2\FileMonitor.Service\AppConfig.xml"; // TODO: Initialize to an appropriate value
            XMLProvider target = new XMLProvider(XMLPath); // TODO: Initialize to an appropriate value
            NameValueCollection actual;
            actual = target.GetAllSpecialValues();
            Assert.AreEqual("36,1,4,8,2,16,4,4,12,12,12,12,12,12,12,12,12,12,12,12,12,12,3,8,36,4,12,10,4,36,10,6", actual["CZInventorySplitArr"]);
           // Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetAllWorkProcess
        ///</summary>
        [TestMethod()]
        public void GetAllWorkProcessTest()
        {
            string XMLPath = @"E:\Dev Version Manage\FileMonitor V2.2\FileMonitor.Service\AppConfig.xml"; // TODO: Initialize to an appropriate value
            XMLProvider target = new XMLProvider(XMLPath); // TODO: Initialize to an appropriate value
            Dictionary<string, WorkProcessBase> actual;
            actual = target.GetAllWorkProcess();
            Assert.AreEqual("1", actual["MonitorHPForecast2003"].BizProcesses[0].NextStatus);
           
        }

        /// <summary>
        ///A test for GetAllWorkProcess
        ///</summary>
        [TestMethod()]
        public void GetAllWorkProcessTest1()
        {
            string XMLPath = string.Empty; // TODO: Initialize to an appropriate value
            XMLProvider target = new XMLProvider(XMLPath); // TODO: Initialize to an appropriate value
            Dictionary<string, WorkProcessBase> expected = null; // TODO: Initialize to an appropriate value
            Dictionary<string, WorkProcessBase> actual;
            actual = target.GetAllWorkProcess();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
